<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
        <title><?php echo $title_for_layout; ?></title>
        <meta name="tags" content="<?php  if(isset($tags)) echo ($tags); ?>"></meta>
        <meta name="description" content="<?php if(isset($metadesc)) __($metadesc); ?>"></meta>
        <meta name="keywords" content="<?php if(isset($keywords)) __($keywords); ?>"></meta>
        <meta name="robots" content="index,follow"></meta>
        <!--FB Open Graph variables -->
        <?php
            $isLogin = $access->isLoggedin();
            if(isset($subject['Subject'])){
                                $thumbnail = $this->PhpThumb->generate(
                                    array(
                                        'save_path' => WWW_ROOT . 'img/uploads/Subjects/thumbs',
                                        'display_path' => 'uploads/Subjects/thumbs',
                                        'error_image_path' => 'noimage.png',
                                        'src' => WWW_ROOT . "img/uploads/Subjects/" . $subject['Subject']['image'],
                                        'w' => 100,
                                        'h' => 100,
                                        'q' => 100,
                                        'zc' => 1
                                    )
                            );?>
        <meta property="og:title" content="<?php echo $title_for_layout; ?>" />
        <meta property="og:type" content="website"/>
        <meta property="og:url" content="http://primeag.org/dev/ratetheu/Subjects/subject/<?php echo $subject['Subject']['id']; ?>"/>
        <meta property="og:site_name" content="Rate The Universe"/>
        <meta property="og:image" content="http://www.primeag.org/dev/ratetheu/img/<?php echo $thumbnail['src']?>"/>
        <meta property="fb:admins" content="digvijaysingh.chauhan"/>
        <meta property="fb:app_id" content="127586310661062"/>
       <!--FB Open Graph variables Ends-->
        
        <?php } ?>
        <link rel="stylesheet" href="<?php echo $this->webroot ?>assets/css/core.css">
        <link rel="stylesheet" href="<?php echo $this->webroot ?>assets/css/home.css">
        <link rel="stylesheet" href="<?php echo $this->webroot ?>assets/jquery-ui/ui-lightness/jq-ui.min.css" />
        <link rel="stylesheet" href="<?php echo $this->webroot ?>assets/jtools/jtools.css">
        <link rel="stylesheet" href="<?php echo $this->webroot ?>assets/jtree/jquery.treeview.css" />
        <link rel="stylesheet" href="<?php echo $this->webroot ?>css/front/pagination/pagination.css" />
        <link rel="stylesheet" href="<?php echo $this->webroot ?>css/front/jquery.fancybox-1.3.4.css" />
        <script src="<?php echo $this->webroot ?>assets/js/script-hdr.min.js"></script>
        <?php echo $this->Javascript->link(array(
            'front/jquery-1.6.2.min',
            array('front/register',
                'front/pagination/jquery.pagination',
                'front/jquery.fancybox-1.3.4.pack',
                'front/report'
                )));?>        
        
        <div id="fb-root"></div>
        <script>
        window.fbAsyncInit = function() {
          FB.init({
            appId      : '127586310661062',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            redirect_uri:'http://primeag.org/dev/ratetheu/staticpages/terms'
          });
        };
        (function(d){
           var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           d.getElementsByTagName('head')[0].appendChild(js);
         }(document));
      </script>
    </head>
    <body>
        <!--[page html]-->

        <?php echo $this->element('login'); ?>
        <?php echo $this->element('register'); ?>
<!--        <div id="dialog" style="width: auto; min-height: 115px; height: auto; " class="ui-dialog-content ui-widget-content" scrolltop="0" scrollleft="0">
            <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
        </div>-->
        <div class='wrap header'>
            <?php 
                if($isLogin)
                {
                    echo $this->element('header_user');
                }
                else
                {
                    echo $this->element('header');  
                }
            ?>
        </div>
        <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
        <div class='wrap page'>
            <div id=main role=main>
                <?php echo $content_for_layout; ?>
            </div>
        </div>  

        <div class='wrap footer'>
            <?php echo $this->element('footer');?>
        </div>
        <script src="<?php echo $this->webroot ?>assets/js/script-ftr.min.js"></script>
        <script src="<?php echo $this->webroot ?>assets/jquery-ui/jq-ui.min.js"></script>
        <script src="<?php echo $this->webroot ?>assets/slidesjs/js/slides.min.js"></script>
        <script src="<?php echo $this->webroot ?>assets/jtools/jtools.min.js"></script>
        <script src="<?php echo $this->webroot ?>assets/jtree/jquery.cookie.js"></script>
        <script src="<?php echo $this->webroot ?>assets/jtree/jquery.treeview.js"></script>
        
        <script>
               
                //Shadowbox.init();
        	
        	$(function() {
        	var base_url=$('#base-url').text();
                //LOGIN
                $('.access').on('click', function() {
                        var sL = $('#secureLogin');
                        sL.fadeIn(600, function(){
                            $('button[type=button]').click(function(){
                                    sL.hide();
                            });
                        });
                });
                //REGISTER
                $('.register').on('click', function() {
                        var sL = $('#secureRegister');
                        sL.fadeIn(600, function(){
                            $('button[type=button]').click(function(){
                                sL.hide();
                            });
                        });
                });
                
                showLoginRegister = function(notShowErr){
                    var sL = $('#secureLogin');
                    sL.fadeIn(600, function(){
                        $('button[type=button]').click(function(){
                            jQuery("#error").hide();
                            sL.hide();
                        });
                    });
                    if(notShowErr==true)
                        jQuery("#error").hide();
                    else{
                        jQuery("#error").show();
                            //jQuery("#error").fadeOut(5000);
                    }
                }
        	
                //SLIDER RANGE
                $( ".slider-range-min" ).slider({
                        range: "min",
                        value: 50,
                        min: 1,
                        max: 100,
                        slide: function( event, ui ) {
                        var rates = this.parentNode.getElementsByClassName('rates')[0];
                rates.value = ui.value;
                change_color(rates.value);
                        }
                });
        		
                $(".rates").val($(".slider-range-min").slider("value"));
        		
                //MAIN SLIDESHOW
                $('#slides').slides({
                        preload: true,
                        preloadImage: '<?php echo $this->webroot ?>assets/slidesjs/img/loading.gif',
                        play: 0
                });
        		
                //THUMB SCROLLER
                $(".scrollable").scrollable();
                
                $('.rateit').on('click', function(){
                   var rates = this.parentNode.getElementsByClassName('rates')[0];
                   $.ajax({
                        url: base_url+"/subjects/rate",
                        type: "POST",
                        data: {
                            subject_id : $(this).val(),
                            rating: rates.value,
                            adj1: '',
                            adj2: '',
                            adj3: ''
                            },
                        dataType: "json",
                        success: function(response){
                            if(!response.error){
                                var subjID = response.subjectID;
                               window.location = base_url + "/subjects/subject/" + subjID +"/1" ;
                            }
                            else
                            {
                                alert("You can't rate a subject twice within seven days!")
                            }
                        }
                    });
                     
                    return false;
                });
                
                $('.tab_button').ready(function(){
        			$('.tab_button button:first').addClass('active');
        			$('.frame_content li:first').css('display', 'block');
        			$('.tab_button button').bind('click',function() {
        				$(this).toggleClass('active').siblings().removeClass('active');
        				var frames = $(this).index(); // all elements have already an index
        				$('.frame_content li:eq('+ frames +')').siblings().hide().end().show();
        			});
        		});
                        
                //Tag Tree
                $("#tree").treeview({
                        collapsed: true,
                        animated: "fast"
                });
        		
                //Tab Function Child
                $('.tab_button_child').ready(function(){
                        $('.tab_button_child button:first').addClass('active');
                        $('.frame_content_child li:first').css('display', 'block');
                        $('.tab_button_child button').bind('click',function() {
                                $(this).toggleClass('active').siblings().removeClass('active');
                                var frames = $(this).index(); // all elements have already an index
                                $('.frame_content_child li:eq('+ frames +')').children().hide().end().show();
                        });
                });
            });
                        
            function change_color(rate_value)
            {
                var i = 0;
                var slides = document.getElementsByClassName("slide");
                for(i = 0; i < slides.length; i++)
                {
                    if(slides[i].style.display != 'none')
                        break;
                }
                var rate_number = document.getElementsByClassName("rates")[i];
                var point_handler = document.getElementsByClassName("ui-slider-handle")[i];
                var base_url = $('#base-url').text();
                if(rate_value >= 1 && rate_value <= 10)
        		{
        			rate_number.style.color = '#C52128';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_1.png)";
        		}
                if(rate_value >= 11 && rate_value <= 20)
        		{
        			rate_number.style.color = '#C95428';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_2.png)";
        		}
        		if(rate_value >= 21 && rate_value <= 30)
        		{
        			rate_number.style.color = '#CC7525';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_3.png)";
        		}
                if(rate_value >= 31 && rate_value <= 40)
        		{
        			rate_number.style.color = '#D2A71C';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_4.png)";
        		}
        		if(rate_value >= 41 && rate_value <= 50)
        		{
        			rate_number.style.color = '#CDC525';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler.png)";
        		}
        		if(rate_value >= 51 && rate_value <= 60)
        		{
        			rate_number.style.color = '#9DB083';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_6.png)";
        		}
        		if(rate_value >= 61 && rate_value <= 70)
        		{
        			rate_number.style.color = '#576A8B';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_7.png)";
        		}
        		if(rate_value >= 71 && rate_value <= 80)
        		{
        			rate_number.style.color = '#344D8D';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_8.png)";
        		}
        		if(rate_value >= 81 && rate_value <= 90)
        		{
        			rate_number.style.color = '#45457B';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_9.png)";
        		}
        		if(rate_value >= 91 && rate_value <= 100)
        		{
        			rate_number.style.color = '#20B57B';
        			point_handler.style.background = "url(" + base_url + "/assets/images/point_handler_10.png)";
        		}
            }
        </script>
        
        <!--[/page html]-->
    <div id="base-url" style="display:none;"><?php echo $this->base; ?></div>
    </body>
</html>